package com.zang.everyday;

/**
 * @author ZVerify
 * @since 2022/11/01 10:21
 * @see <a href="https://leetcode.cn/problems/check-if-two-string-arrays-are-equivalent/">...</a>
 **/
public class 检查两个字符数组是否相等 {

    public boolean arrayStringsAreEqual(String[] word1, String[] word2) {

        int i1=0,j1=0,i2=0,j2=0;
        while (i1<word1.length && i2<word1.length) {
            if (word1[i1].charAt(j1)==word2[i2].charAt(j2)){
                ++j1;
                ++j2;
                if (j1==word1[i1].length()) {
                    ++i1;
                    j1 = 0;
                }
                if (j2==word2[i2].length()) {
                    ++i2;
                    j2 = 0;
                }
            }else {
                return false;
            }
        }
        return i1 == word1.length && i2 == word2.length;
    }
}
